/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dog.service.impl;

import com.dog.dao.DAO;
import com.dog.model.BaseEntity;
import com.dog.service.IBaseService;

import java.util.List;

/**
 * User: Kuttubek Aidaraliev
 * Date: 02.04.2010
 * Time: 08:52:04
 */
public abstract class BaseService<D extends DAO<E>, E extends BaseEntity> implements IBaseService<D, E> {

    @Override
    public E get(Long id) {
        return getDao().findById(id);
    }

    @Override
    public E save(E entity) {
        getDao().save(entity);
        return entity;
    }

    @Override
    public void update(E entity) {
        getDao().update(entity);
    }

    @Override
    public void delete(E entity) {
        getDao().delete(entity);
    }

    @Override
    public int getTotalCount() {
        return getDao().getTotalCount();
    }

    @Override
    public List<E> getByRange(int start, int count, String field, boolean asc) {
        return getDao().getByRange(start, count, field, asc);
    }

    @Override
    public List<E> getAll() {
        return getDao().list();
    }

}
